package com.jiukuaidao.library.glide;

import android.content.Context;
import android.os.Environment;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import com.bumptech.glide.module.GlideModule;

import java.io.InputStream;

/**
 * Author : PaiTaSuo
 * Date : 2016/5/20
 * Description :
 */
public class CustomCachingGlideModule implements GlideModule {
    /***
     * 图片根路径 sd卡/APP/
     */
    public final static String BASE_PIC_URI = Environment.getExternalStorageDirectory() + "/App/";
//    String BASE_PIC_URI = Environment.getDownloadCacheDirectory() + "/App/";


    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        int cacheSize100MegaBytes = 104857600;
        builder.setDiskCache(new DiskLruCacheFactory(BASE_PIC_URI, cacheSize100MegaBytes));
    }

    @Override
    public void registerComponents(Context context, Glide glide) {
        glide.register(CustomImageSizeModel.class, InputStream.class, new CustomImageSizeModelFactory());

    }
}
